AM_CPPFLAGS += -DLOCALEDIR=\"$(localedir)\" \
    -I$(top_srcdir)/src/arch \
    -I$(top_srcdir)/src/lstm \
    -I$(top_srcdir)/src/ccutil \
    -I$(top_srcdir)/src/ccstruct \
    -I$(top_srcdir)/src/viewer \
    -I$(top_srcdir)/src/textord \
    -I$(top_srcdir)/src/dict \
    -I$(top_srcdir)/src/classify \
    -I$(top_srcdir)/src/ccmain \
    -I$(top_srcdir)/src/wordrec \
    -I$(top_srcdir)/src/cutil \
    -I$(top_srcdir)/src/opencl \
    -I$(top_builddir)/api

AM_CPPFLAGS += $(OPENCL_CPPFLAGS)

if VISIBILITY
AM_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif

pkginclude_HEADERS = apitypes.h baseapi.h capi.h renderer.h tess_version.h
lib_LTLIBRARIES = 

noinst_LTLIBRARIES = libtesseract_api.la

libtesseract_api_la_CPPFLAGS = $(AM_CPPFLAGS)
if VISIBILITY
libtesseract_api_la_CPPFLAGS += -DTESS_EXPORTS
endif
libtesseract_api_la_SOURCES = baseapi.cpp capi.cpp renderer.cpp pdfrenderer.cpp

lib_LTLIBRARIES += libtesseract.la
libtesseract_la_LDFLAGS = $(LEPTONICA_LIBS) $(OPENCL_LDFLAGS)
libtesseract_la_SOURCES =
# Dummy C++ source to cause C++ linking.
# see http://www.gnu.org/s/hello/manual/automake/Libtool-Convenience-Libraries.html#Libtool-Convenience-Libraries
nodist_EXTRA_libtesseract_la_SOURCES = dummy.cxx
libtesseract_la_LIBADD = \
    libtesseract_api.la \
    ../ccmain/libtesseract_main.la \
    ../textord/libtesseract_textord.la \
    ../wordrec/libtesseract_wordrec.la \
    ../classify/libtesseract_classify.la \
    ../dict/libtesseract_dict.la \
    ../arch/libtesseract_arch.la \
    ../arch/libtesseract_avx.la \
    ../arch/libtesseract_avx2.la \
    ../arch/libtesseract_sse.la \
    ../lstm/libtesseract_lstm.la \
    ../ccstruct/libtesseract_ccstruct.la \
    ../cutil/libtesseract_cutil.la \
    ../viewer/libtesseract_viewer.la \
    ../ccutil/libtesseract_ccutil.la \
    ../opencl/libtesseract_opencl.la 

libtesseract_la_LDFLAGS += -version-info $(GENERIC_LIBRARY_VERSION) -no-undefined

bin_PROGRAMS = tesseract
tesseract_SOURCES = tesseractmain.cpp
tesseract_CPPFLAGS = $(AM_CPPFLAGS)
if VISIBILITY
tesseract_CPPFLAGS += -DTESS_IMPORTS
endif

tesseract_LDADD = libtesseract.la


tesseract_LDFLAGS = $(OPENCL_LDFLAGS)

tesseract_LDADD += $(LEPTONICA_LIBS)
tesseract_LDADD += $(OPENMP_CXXFLAGS)

if T_WIN
tesseract_LDADD += -ltiff
tesseract_LDADD += -lws2_32
libtesseract_la_LDFLAGS += -no-undefined -Wl,--as-needed -lws2_32
endif
if ADD_RT
tesseract_LDADD += -lrt
endif
